using System;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Exceptions;

namespace Me.Prettyprint.Hector.Api.Locking
{
    /// <summary>
    /// Entity responsible for managing locks acquisition.
    /// </summary>
	public interface HLockManager
	{
		void Init();
        Cluster Cluster
        {
            get;
            set;
        }
        Keyspace Keyspace
        {
            get;
            set;
        }
        HLockManagerConfigurator LockManagerConfigurator
        {
            get;
            set;
        }
        /// <summary>
        /// Acquires a lock represented by lock.getPath and filling up the lockId with
        /// a unique client/caller lock id.  This method will block until a lock is 
        /// returned, or timeout is reached
        /// </summary>
        /// <param name="hlock"></param>
        /// <param name="timeout"></param>
		void Acquire(HLock hlock, long timeout);
        /// <summary>
        /// Acquires a lock represented by lock.getPath and filling up the lockId with
        /// a unique client/caller lock id.  This method will block until a lock is returned
        /// </summary>
        /// <param name="hlock"></param>
        void Acquire(HLock hlock);
        /// <summary>
        /// Releases the lock
        /// </summary>
        /// <param name="hlock"></param>
        void Release(HLock hlock);
        /// <summary>
        /// Creates a lock instance to use later on acquire(HLock)
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
		HLock CreateLock(string value);
	}
}